package com.looookme.shaozhuo.datasave;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * Created by Shaozhuo on 2015/9/11.
 */
public class DBOpenHelper extends SQLiteOpenHelper {
    //SQLiteDataBase帮助类

    public DBOpenHelper(Context context, String name) {
        super(context, name, null, 1);
    }

    public DBOpenHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
        super(context, name, factory, version);
    }

    //创建数据库时候调用，一般用于数据库创建及表的创建
    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL("create table if not exists tb_user(_id integer primary key autoincrement, name text not null, age integer not null, sex text not null)");
    }

    //版本更新时调用
    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }
}
